package com.darker.yygh.controller;

import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import com.atguigu.yygh.vo.hosp.HospitalSetQueryVo;
import com.darker.yygh.result.Result;
import com.darker.yygh.service.HospitalService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

//@CrossOrigin
@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {
    @Autowired
    HospitalService hospitalService;
    //医院列表 （条件带分页查询）
    @GetMapping("/list/{page}/{limit}")
    public Result listHospital(@PathVariable Integer page, @PathVariable Integer limit,  HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pageMondel=hospitalService.selectHospPage(page,limit,hospitalQueryVo);
        return Result.ok(pageMondel);
    }
    //更新医院状态值
    @PutMapping("/updateStatus/{id}/{status}")
    public Result updateStatus(@PathVariable String id,@PathVariable Integer status){
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }
    //医院详情信息
    @ApiOperation("医院详情信息")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id){
       Map<String,Object> map= hospitalService.findHospById(id);
       return Result.ok(map);
    }

}
